package com.jmpt.fangbohui.helper;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;

import com.google.gson.Gson;
import com.jmpt.fangbohui.Constants;
import com.jmpt.fangbohui.bean.AgentListFilterBean.ZoneZjcompanyListEntity;
import com.jmpt.fangbohui.bean.HouseMoreCategoryItemValuesBean;
import com.jmpt.fangbohui.bean.HouseMoreSeleteCategoryBean;
import com.jmpt.fangbohui.bean.HouseProportionBean;
import com.jmpt.fangbohui.bean.NewHouseFilterBean;
import com.jmpt.fangbohui.bean.NewHouseFilterBean.OrderSUPListEntity;
import com.jmpt.fangbohui.bean.AgentListFilterBean;
import com.jmpt.fangbohui.bean.NewHouseOrderBean;
import com.jmpt.fangbohui.bean.HousePriceBean;
import com.jmpt.fangbohui.bean.HouseRegionBean;
import com.jmpt.fangbohui.bean.OldHouseFilterBean;
import com.jmpt.fangbohui.bean.OrderStateBean;
import com.jmpt.fangbohui.bean.OrderTypeBean;
import com.jmpt.fangbohui.bean.RecommendBean;
import com.jmpt.fangbohui.bean.RentHouseFilterBean;
import com.jmpt.fangbohui.bean.RentHouseFilterBean.H_roomListEntity;
import com.jmpt.fangbohui.bean.RentHouseFilterBean.Ho_lxListEntity;
import com.jmpt.fangbohui.bean.RentHouseFilterBean.OrderMJListEntity;
import com.jmpt.fangbohui.bean.RentHouseFilterBean.OrderRPListEntity;
import com.jmpt.fangbohui.bean.RentHouseFilterBean.OrderTimeListEntity;
import com.jmpt.fangbohui.utils.FileUtils;

/**
 * 
 * @author Victor
 * 
 */
public class CommonHelper {
	/**
	 * 填充一个推荐条目视图
	 * 
	 * @param context
	 * @param recommendBean
	 * @param position
	 * @return
	 */
	public static View getHomeRecommendsView(Context context,
			RecommendBean recommendBean, int position) {
		// TODO 填充一个推荐条目视图
		return null;
	}

	public static List<HouseRegionBean> getHouseRegionBeans() {
		
		List<HouseRegionBean> houseRegionBeans = new ArrayList<HouseRegionBean>();
		houseRegionBeans.add(createNewHouseRegionBean(0, "不限", false));
		houseRegionBeans.add(createNewHouseRegionBean(1, "蓬江", false));
		houseRegionBeans.add(createNewHouseRegionBean(2, "江海", false));
		houseRegionBeans.add(createNewHouseRegionBean(3, "新会", false));
		houseRegionBeans.add(createNewHouseRegionBean(4, "鹤山", false));
		houseRegionBeans.add(createNewHouseRegionBean(5, "台山", false));
		houseRegionBeans.add(createNewHouseRegionBean(6, "开平", false));
		houseRegionBeans.add(createNewHouseRegionBean(7, "恩平", false));
		return houseRegionBeans;
	}
	
	/**
	 * 获取二手房 地区过滤
	 * @return
	 */
	public static List<HouseRegionBean> getRentHouseRegionBeans() {
		
		RentHouseFilterBean filter = getRentHouseFilter();
		
		if(filter != null){
			List<HouseRegionBean> zoneList = filter.zoneList;
			HouseRegionBean defult = new HouseRegionBean();
			defult.ZoneName = "不限";
			defult.ZoneID = 0;
			zoneList.add(0, defult);
			return zoneList;
		}
		return null;
		/*List<HouseRegionBean> houseRegionBeans = new ArrayList<HouseRegionBean>();
		houseRegionBeans.add(createNewHouseRegionBean(0, "不限", false));
		houseRegionBeans.add(createNewHouseRegionBean(1, "蓬江", false));
		houseRegionBeans.add(createNewHouseRegionBean(2, "江海", false));
		houseRegionBeans.add(createNewHouseRegionBean(3, "新会", false));
		houseRegionBeans.add(createNewHouseRegionBean(4, "鹤山", false));
		houseRegionBeans.add(createNewHouseRegionBean(5, "台山", false));
		houseRegionBeans.add(createNewHouseRegionBean(6, "开平", false));
		houseRegionBeans.add(createNewHouseRegionBean(7, "恩平", false));
		return houseRegionBeans;
		*/
	}
	
	
	/**
	 * 获取二手房 地区筛选 条件
	 * @return
	 */
	public static List<HouseRegionBean> getOldHouseRegionBeans() {
		
		OldHouseFilterBean filter = getOldHouseFilter();
		
		if(filter != null){
			List<HouseRegionBean> zoneList = filter.zoneList;
			HouseRegionBean defult = new HouseRegionBean();
			defult.ZoneName = "不限";
			defult.ZoneID = 0;
			zoneList.add(0, defult);
			return zoneList;
		}
		return null;
		/*List<HouseRegionBean> houseRegionBeans = new ArrayList<HouseRegionBean>();
		houseRegionBeans.add(createNewHouseRegionBean(0, "不限", false));
		houseRegionBeans.add(createNewHouseRegionBean(1, "蓬江", false));
		houseRegionBeans.add(createNewHouseRegionBean(2, "江海", false));
		houseRegionBeans.add(createNewHouseRegionBean(3, "新会", false));
		houseRegionBeans.add(createNewHouseRegionBean(4, "鹤山", false));
		houseRegionBeans.add(createNewHouseRegionBean(5, "台山", false));
		houseRegionBeans.add(createNewHouseRegionBean(6, "开平", false));
		houseRegionBeans.add(createNewHouseRegionBean(7, "恩平", false));
		return houseRegionBeans;
		 */
	}
	/**
	 * 获取新房 区域筛选条件
	 * @return
	 */
	public static List<HouseRegionBean> getNewHouseRegionBeans() {
		
		NewHouseFilterBean filter = getNewHouseFilter();
		
		if(filter != null){
			List<HouseRegionBean> zoneList = filter.zoneList;
			HouseRegionBean defult = new HouseRegionBean();
			defult.ZoneName = "不限";
			defult.ZoneID = 0;
			zoneList.add(0, defult);
			return zoneList;
		}
		return null;
		/*List<HouseRegionBean> houseRegionBeans = new ArrayList<HouseRegionBean>();
		houseRegionBeans.add(createNewHouseRegionBean(0, "不限", false));
		houseRegionBeans.add(createNewHouseRegionBean(1, "蓬江", false));
		houseRegionBeans.add(createNewHouseRegionBean(2, "江海", false));
		houseRegionBeans.add(createNewHouseRegionBean(3, "新会", false));
		houseRegionBeans.add(createNewHouseRegionBean(4, "鹤山", false));
		houseRegionBeans.add(createNewHouseRegionBean(5, "台山", false));
		houseRegionBeans.add(createNewHouseRegionBean(6, "开平", false));
		houseRegionBeans.add(createNewHouseRegionBean(7, "恩平", false));
		return houseRegionBeans;
		 */
	}
	
	/**
	 * 获经纪人 区域筛选条件
	 * @return
	 */
	public static List<HouseRegionBean> getAgentRegionBeans() {
		
		 AgentListFilterBean filter = getAgentFilterBean();
		
		if(filter != null){
			List<HouseRegionBean> zoneList = filter.zoneList;
			HouseRegionBean defult = new HouseRegionBean();
			defult.ZoneName = "不限";
			defult.ZoneID = 0;
			zoneList.add(0, defult);
			return zoneList;
		}
		return null;
	}

	private static RentHouseFilterBean getRentHouseFilter() {
		String string = FileUtils.readJsonCache(Constants.SharedPreferences.RENT_HOUSE_FILTER);
		if(!TextUtils.isEmpty(string)){
			Gson gson = new Gson();
			try{
				return gson.fromJson(string, RentHouseFilterBean.class);
			}catch(Exception e){
			}
		}
		//本地没有 或解析出错  都要重新获取服务器的
		return null;
	}
	
	private static OldHouseFilterBean getOldHouseFilter() {
		String string = FileUtils.readJsonCache(Constants.SharedPreferences.OLD_HOUSE_FILTER);
		if(!TextUtils.isEmpty(string)){
			Gson gson = new Gson();
			try{
				return gson.fromJson(string, OldHouseFilterBean.class);
			}catch(Exception e){
			}
		}
		//本地没有 或解析出错  都要重新获取服务器的
		return null;
	}
	
	private static NewHouseFilterBean getNewHouseFilter() {
		String string = FileUtils.readJsonCache(Constants.SharedPreferences.NEW_HOUSE_FILTER);
		if(!TextUtils.isEmpty(string)){
			Gson gson = new Gson();
			try{
				return gson.fromJson(string, NewHouseFilterBean.class);
			}catch(Exception e){
			}
		}
		//本地没有 或解析出错  都要重新获取服务器的
		return null;
	}

	/**
	 * 获取新房 价格筛选 
	 * @return
	 */
	public static List<HousePriceBean> getNewHousePriceBeans() {
		NewHouseFilterBean newHouseFilter = getNewHouseFilter();
		if(newHouseFilter != null){
			List<HousePriceBean> priceList = newHouseFilter.priceList;
			HousePriceBean defult = new HousePriceBean();
			defult.PriceID = "";
			defult.PriceName = "不限";
			priceList.add(0, defult);
			return priceList;
		}

		return null;
	}

	@Deprecated
	public static List<HousePriceBean> getOldHouseTotalPriceBeans() {

		String[] nameStrings = { "不限", "100万以下", "100-150万", "150-200万",
				"200-300万", "300-500万", "500-1000万", "1000万以上" };
		String[] priceStrings = { "", "0_100", "100_150", "150_200", "200_300",
				"300_500", "500_1000", "1000_" };

		return getHousePriceListFromArr(nameStrings, priceStrings);
	}

	@Deprecated
	public static List<HousePriceBean> getHouseRentalBeans() {
		String[] nameStrings = { "不限", "300元以下", "300-500元", "500-800元",
				"800-1200元", "1200-2000元", "2000-3000元", "3000-4500元",
				"4500-6000元", "6000元以上" };
		String[] priceStrings = { "", "0_300", "300_500", "500_800",
				"800_1200", "1200_2000", "2000_3000", "3000_4500", "4500_6000",
				"6000_" };

		return getHousePriceListFromArr(nameStrings, priceStrings);
	}
	
	/**
	 * 获取二手房价格 筛选
	 * @return
	 */
	public static List<HousePriceBean> getRentHouseRentalBeans() {
		RentHouseFilterBean rentHouseFilter = getRentHouseFilter();
		if(rentHouseFilter != null){
			List<HousePriceBean> priceList = rentHouseFilter.priceList;
			HousePriceBean defult = new HousePriceBean();
			defult.PriceID = "";
			defult.PriceName = "不限";
			priceList.add(0, defult);
			return priceList;
		}

		return null;
	}
	
	/**
	 * 获取二手房 价格筛选条件
	 * @return
	 */
	public static List<HousePriceBean> getOldHousePriceBeans() {
		OldHouseFilterBean oldHouseFilter = getOldHouseFilter();
		if(oldHouseFilter != null){
			List<HousePriceBean> priceList = oldHouseFilter.priceList;
			HousePriceBean defult = new HousePriceBean();
			defult.PriceID = "";
			defult.PriceName = "不限";
			priceList.add(0, defult);
			return priceList;
		}
		
		return null;
	}

	public static List<HousePriceBean> getHousePriceListFromArr(
			String[] nameStrings, String[] priceStrings) {
		List<HousePriceBean> housePriceBeans = new ArrayList<HousePriceBean>();
		HousePriceBean bean;
		for (int i = 0; i < nameStrings.length; i++) {
			bean = new HousePriceBean();
			bean.PriceName = nameStrings[i];
			bean.PriceID = priceStrings[i];
			housePriceBeans.add(bean);
		}
		return housePriceBeans;
	}

	@Deprecated
	public static List<HouseProportionBean> getHouseProportionBeans() {
		List<HouseProportionBean> houseProportionBeans = new ArrayList<HouseProportionBean>();
		String[] nameStrings = { "不限", "50平米以下", "50-70平米", "70-90平米",
				"90-110平米", "110-130平米", "130-150平米", "150-200平米", "200平米以上" };
		String[] priceStrings = { "", "0_50", "50_70", "70_90", "90_110",
				"110_130", "130_150", "150_200", "200_" };
		HouseProportionBean bean;
		for (int i = 0; i < nameStrings.length; i++) {
			bean = new HouseProportionBean();
			bean.h_mjName = nameStrings[i];
			bean.h_mjID = priceStrings[i];
			houseProportionBeans.add(bean);
		}
		return houseProportionBeans;
	}
	
	/**
	 * 获取租房 面积筛选
	 * @return
	 */
	public static List<HouseProportionBean> getRentHouseProportionBeans() {
		RentHouseFilterBean rentHouseFilter = getRentHouseFilter();
		if(rentHouseFilter != null){
			List<HouseProportionBean> h_mjList = rentHouseFilter.h_mjList;
			HouseProportionBean defult = new HouseProportionBean();
			defult.h_mjID = "";
			defult.h_mjName = "不限";
			h_mjList.add(0, defult);
			return h_mjList;
		}
		return null;
	}
	
	/**
	 * 获取二手房 面积筛选
	 * @return
	 */
	public static List<HouseProportionBean> getOldHouseProportionBeans() {
		OldHouseFilterBean oldHouseFilter = getOldHouseFilter();
		if(oldHouseFilter != null){
			List<HouseProportionBean> h_mjList = oldHouseFilter.h_mjList;
			HouseProportionBean defult = new HouseProportionBean();
			defult.h_mjID = "";
			defult.h_mjName = "不限";
			h_mjList.add(0, defult);
			return h_mjList;
		}
		return null;
	}

	/**
	 * 获取新房 排序 方式
	 * @return
	 */
	public static List<NewHouseOrderBean> getNewHouseOrderBeans() {
		/*
		 * $_GET['orderSUP']=="asc" 按照单价升序排序 $_GET['orderSUP']=="desc" 按照单价降序排序
		 * $_GET['orderTime']=="asc" 按照时间升序排序 $_GET['orderTime']=="desc"
		 * 按照时间降序排序 $_GET["orderTime"] 默认排序
		 */
		
		NewHouseFilterBean newHouseFilter = getNewHouseFilter();
		List<NewHouseOrderBean> houseOrderBeans = null;
		if(newHouseFilter != null){
			houseOrderBeans = new ArrayList<NewHouseOrderBean>();
			NewHouseOrderBean bean;
			//默认
			bean = new NewHouseOrderBean();
			bean.name = "默认排序";
			bean.type = "orderTime";
			houseOrderBeans.add(bean);
			
			for (OrderSUPListEntity orderSUPListEntity : newHouseFilter.orderSUPList) {
				bean = new NewHouseOrderBean();
				bean.name = orderSUPListEntity.orderSUPName;
				bean.type = "orderSUP=" + orderSUPListEntity.orderSUPID;
				houseOrderBeans.add(bean);
			}
			for (NewHouseFilterBean.OrderTimeListEntity orderTimeListEntity : newHouseFilter.orderTimeList) {
				bean = new NewHouseOrderBean();
				bean.name = orderTimeListEntity.orderTimeName;
				bean.type = "orderTime=" + orderTimeListEntity.orderTimeID;
				houseOrderBeans.add(bean);
			}
		}
		
		return houseOrderBeans;
	}
	/**
	 * 获取新房 排序 方式
	 * @return
	 */
	public static List<NewHouseOrderBean> getBrokerListHouseOrderBeans() {
		/*
		 $_GET['orderSUP']=="asc"	按照单价升序排序
		$_GET['orderSUP']=="desc"	按照单价降序排序
		$_GET['orderSP']=="asc"	按照总价升序排序
		$_GET['orderSP']=="desc"	按照总价降序排序
		$_GET['orderMJ']=="asc"	按照面积升序排序
		$_GET['orderMJ']=="desc"	按照面积降序排序
		$_GET['orderTime']=="asc"	按照时间升序排序
		$_GET['orderTime']=="desc"	按照时间降序排序
		 */
		
		NewHouseFilterBean newHouseFilter = getNewHouseFilter();
		List<NewHouseOrderBean> houseOrderBeans = null;
		if(newHouseFilter != null){
			houseOrderBeans = new ArrayList<NewHouseOrderBean>();
			NewHouseOrderBean bean;
			//默认
			bean = new NewHouseOrderBean();
			bean.name = "默认排序";
			bean.type = "orderSUP";
			houseOrderBeans.add(bean);
			//按照单价升序排序
			bean = new NewHouseOrderBean();
			bean.name = "按照单价升序排序";
			bean.type = "orderSUP=asc";
			houseOrderBeans.add(bean);
			//按照单价降序排序
			bean = new NewHouseOrderBean();
			bean.name = "按照单价降序排序";
			bean.type = "orderSUP=desc";
			houseOrderBeans.add(bean);
			//按照总价升序排序
			bean = new NewHouseOrderBean();
			bean.name = "按照总价升序排序";
			bean.type = "orderSP=asc";
			houseOrderBeans.add(bean);
			//按照总价降序排序
			bean = new NewHouseOrderBean();
			bean.name = "按照总价降序排序";
			bean.type = "orderSP=desc";
			houseOrderBeans.add(bean);
			//按照面积升序排序
			bean = new NewHouseOrderBean();
			bean.name = "按照面积升序排序";
			bean.type = "orderMJ=asc";
			houseOrderBeans.add(bean);
			//按照面积降序排序
			bean = new NewHouseOrderBean();
			bean.name = "按照面积降序排序";
			bean.type = "orderMJ=desc";
			houseOrderBeans.add(bean);
			//按照时间升序排序
			bean = new NewHouseOrderBean();
			bean.name = "按照时间升序排序";
			bean.type = "orderTime=asc";
			houseOrderBeans.add(bean);
			//按照时间降序排序
			bean = new NewHouseOrderBean();
			bean.name = "按照时间降序排序";
			bean.type = "orderTime=desc";
			houseOrderBeans.add(bean);
			
//			for (OrderSUPListEntity orderSUPListEntity : newHouseFilter.orderSUPList) {
//				bean = new NewHouseOrderBean();
//				bean.name = orderSUPListEntity.orderSUPName;
//				bean.type = "orderSUP=" + orderSUPListEntity.orderSUPID;
//				houseOrderBeans.add(bean);
//			}
//			
//			for (NewHouseFilterBean.OrderTimeListEntity orderTimeListEntity : newHouseFilter.orderTimeList) {
//				bean = new NewHouseOrderBean();
//				bean.name = orderTimeListEntity.orderTimeName;
//				bean.type = "orderTime=" + orderTimeListEntity.orderTimeID;
//				houseOrderBeans.add(bean);
//			}
		}
		
		return houseOrderBeans;
	}

	@Deprecated
	public static List<HouseMoreSeleteCategoryBean> getHouseMoreCategoryBeans() {
		List<HouseMoreSeleteCategoryBean> houseMoreCategoryBeans = new ArrayList<HouseMoreSeleteCategoryBean>();
		/*
		 * { Map<String, String> structure = new LinkedHashMap<String,
		 * String>(); structure.put("不限", ""); structure.put("一房", "1");
		 * structure.put("两房", "2"); structure.put("三房", "3");
		 * structure.put("四房", "4"); structure.put("五房", "5");
		 * structure.put("五房以上", "6");
		 * houseMoreCategoryBeans.add(getHouseMoreCategoryItem("户型",
		 * "houseStru", structure)); } { Map<String, String> houseType = new
		 * LinkedHashMap<String, String>(); houseType.put("不限", "");
		 * houseType.put("住宅", "1"); houseType.put("别墅", "2");
		 * houseType.put("商铺", "3"); houseType.put("写字楼", "4");
		 * houseType.put("厂房", "5"); houseType.put("车位", "6");
		 * houseType.put("洋房", "7"); houseType.put("地皮", "8");
		 * houseType.put("车房上", "9");
		 * houseMoreCategoryBeans.add(getHouseMoreCategoryItem("房屋类型",
		 * "houseStru", houseType)); }
		 */
		{
			/*
			 * $_GET["orderSUP"] 默认排序（order by LastUpDate desc）
			 * $_GET['orderSUP']=="asc" 按照单价升序排序 
			 * $_GET['orderSUP']=="desc" 按照单价降序排序
			 * $_GET['orderSP']=="asc" 按照总价升序排序 
			 * $_GET['orderSP']=="desc" 按照总价降序排序
			 * $_GET['orderMJ']=="asc" 按照面积升序排序
			 *  $_GET['orderMJ']=="desc" 按照面积降序排序
			 * $_GET['orderTime']=="asc" 按照时间升序排序 
			 * $_GET['orderTime']=="desc" 按照时间降序排序
			 */
			Map<String, String> orderType = new LinkedHashMap<String, String>();
			orderType.put("默认排序", "orderSUP");
			orderType.put("单价由低到高", "orderSUP=asc");
			orderType.put("单价由高到低", "orderSUP=desc");
			orderType.put("总价由低到高", "orderSP=asc");
			orderType.put("总价由高到低", "orderSP=desc");
			orderType.put("面积由小到大", "orderMJ=asc");
			orderType.put("面积由大到小", "orderMJ=desc");
			orderType.put("发布时间升序", "orderTime=asc");
			orderType.put("时间时间降序", "orderTime=desc");
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("排序",
					"orderSUP", orderType));
		}
		return houseMoreCategoryBeans;
	}
	
	/**
	 * 获取租房更多 筛选条件
	 * @return
	 */
	public static List<HouseMoreSeleteCategoryBean> getRentHouseMoreCategoryBeans() {
		String json = FileUtils.readJsonCache(Constants.SharedPreferences.RENT_HOUSE_FILTER);
		if(json == null){
			return null;
		}
		Gson g = new Gson();
		RentHouseFilterBean houseFilterBean;
		try {
			houseFilterBean = g.fromJson(json, RentHouseFilterBean.class);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
		List<HouseMoreSeleteCategoryBean> houseMoreCategoryBeans = new ArrayList<HouseMoreSeleteCategoryBean>();
		{
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("户型",
					"H_Room", getRentHouseRoomMap(houseFilterBean.h_roomList)));
		}
		{
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("房屋类型",
						"LXID", getRentHouseLXMap(houseFilterBean.ho_lxList)));
		}
		/*{
			Map<String, String> orderType = new LinkedHashMap<String, String>();
			orderType.put("默认排序", "");
			orderType.put("单价由低到高", "orderSUP=asc");
			orderType.put("单价由高到低", "orderSUP=desc");
			orderType.put("总价由低到高", "orderSP=asc");
			orderType.put("总价由高到低", "orderSP=desc");
			orderType.put("面积由小到大", "orderMJ=asc");
			orderType.put("面积由大到小", "orderMJ=desc");
			orderType.put("发布时间升序", "orderTime=asc");
			orderType.put("时间时间降序", "orderTime=desc");
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("排序",
					"orderSUP", orderType));
		}*/
		{
			//orderRP 租金排序
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("排序",
					"order", getRentHouseOrderMap(houseFilterBean)));
		}
		return houseMoreCategoryBeans;
	}
	
	/**
	 * 获取租房更多 筛选条件
	 * @return
	 */
	public static List<HouseMoreSeleteCategoryBean> getOldHouseMoreCategoryBeans() {
		String json = FileUtils.readJsonCache(Constants.SharedPreferences.OLD_HOUSE_FILTER);
		if(json == null){
			return null;
		}
		Gson g = new Gson();
		OldHouseFilterBean houseFilterBean;
		try {
			houseFilterBean = g.fromJson(json, OldHouseFilterBean.class);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
		List<HouseMoreSeleteCategoryBean> houseMoreCategoryBeans = new ArrayList<HouseMoreSeleteCategoryBean>();
		{
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("户型",
					"H_Room", getOldHouseRoomMap(houseFilterBean.h_roomList)));
		}
		{
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("房屋类型",
					"LXID", getOldHouseLXMap(houseFilterBean.ho_lxList)));
		}
		{
			//排序
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("排序",
					"order", getOldHouseOrderMap(houseFilterBean)));
		}
		return houseMoreCategoryBeans;
	}
	
	/**
	 * 获取经纪人 区域 筛选条件
	 * @return
	 */
	public static List<HouseMoreSeleteCategoryBean> getBrokerAgentListBeans() {
		
		AgentListFilterBean filterBean = getAgentFilterBean();
		
		if(filterBean == null){
			return null;
		}
		List<HouseMoreSeleteCategoryBean> houseMoreCategoryBeans = new ArrayList<HouseMoreSeleteCategoryBean>();
		HouseMoreSeleteCategoryBean categoryBean = new HouseMoreSeleteCategoryBean();
		
		categoryBean.name = "不限";
		categoryBean.values = new ArrayList<HouseMoreCategoryItemValuesBean>(); //初始化一个 size = 0;
//		categoryBean.values.add(new HouseMoreCategoryItemValuesBean());
		houseMoreCategoryBeans.add(categoryBean);
		
		for (ZoneZjcompanyListEntity zoneBean : filterBean.zoneZjcompanyList) {
			categoryBean = new HouseMoreSeleteCategoryBean();
			categoryBean.name = zoneBean.zoneZjcompanyName;
			categoryBean.id = zoneBean.zoneID;
			houseMoreCategoryBeans.add(categoryBean);
		}
		return houseMoreCategoryBeans;
	}

	private static AgentListFilterBean getAgentFilterBean() {
		String json = FileUtils.readJsonCache(Constants.SharedPreferences.AGENT_LIST_FILTER);
		if(json == null){
			return null;
		}
		Gson g = new Gson();
		AgentListFilterBean filterBean;
		try {
			filterBean = g.fromJson(json, AgentListFilterBean.class);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return filterBean;
	}
	
	/**
	 * 获取租房 所有排序 方式
	 * @param houseFilterBean
	 * @return
	 */
	private static Map<String, String> getRentHouseOrderMap(
			RentHouseFilterBean houseFilterBean) {
		// orderRP 租金排序
		Map<String, String> orderMap = getRentHousePriceMap(houseFilterBean.orderRPList);
		// orderMJ 面积排序方式
		orderMap.putAll(getRentHouseMJOrderMap(houseFilterBean.orderMJList));
		// orderTime 时间排序方式
		orderMap.putAll(getRentHouseTimeMap(houseFilterBean.orderTimeList));
		return orderMap;
	}
	
	/**
	 * 获取二手房 所有排序 方式
	 * @param houseFilterBean
	 * @return
	 */
	private static Map<String, String> getOldHouseOrderMap(
			OldHouseFilterBean houseFilterBean) {
		// orderSUP 总价排序
		Map<String, String> orderMap = getOldHouseUnitPriceMap(houseFilterBean.orderSUPList);
		// orderSP 总价排序
		orderMap.putAll(getOldHouseTotalPriceMap(houseFilterBean.orderSPList));
		// orderMJ 面积排序方式
		orderMap.putAll(getOldHouseMJOrderMap(houseFilterBean.orderMJList));
		// orderTime 时间排序方式
		orderMap.putAll(getOldHouseTimeMap(houseFilterBean.orderTimeList));
		return orderMap;
	}

	/**
	 * 获取租房 时间 排序 方式
	 * @param orderTimeList
	 * @return
	 */
	private static Map<String, String> getRentHouseTimeMap(
			List<OrderTimeListEntity> orderTimeList) {
		Map<String, String> TimeMap = new LinkedHashMap<String, String>();
		TimeMap.put("不限", "");
		for (OrderTimeListEntity orderTimeListEntity : orderTimeList) {
			TimeMap.put(orderTimeListEntity.orderTimeName, "orderTime=" + orderTimeListEntity.orderTimeID);//orderTime=asc
		}
		return TimeMap;
	}
	
	/**
	 * 获取二手房 时间 排序 方式
	 * @param orderTimeList
	 * @return
	 */
	private static Map<String, String> getOldHouseTimeMap(
			List<OldHouseFilterBean.OrderTimeListEntity> orderTimeList) {
		Map<String, String> TimeMap = new LinkedHashMap<String, String>();
		TimeMap.put("不限", "");
		for (OldHouseFilterBean.OrderTimeListEntity orderTimeListEntity : orderTimeList) {
			TimeMap.put(orderTimeListEntity.orderTimeName, "orderTime=" + orderTimeListEntity.orderTimeID);//orderTime=asc
		}
		return TimeMap;
	}

	/**
	 * 获取租房 面积排序 方式
	 * @param orderMJList
	 * @return
	 */
	private static Map<String, String> getRentHouseMJOrderMap(
			List<OrderMJListEntity> orderMJList) {
		Map<String, String> MJMap = new LinkedHashMap<String, String>();
		MJMap.put("不限", "");
		for (OrderMJListEntity orderMJListEntity : orderMJList) {
			MJMap.put(orderMJListEntity.orderMJName, "orderMJ=" + orderMJListEntity.orderMJID);//orderMJ=asc
		}
		return MJMap;
	}
	
	/**
	 * 获取二手房房 面积排序 方式
	 * @param orderMJList
	 * @return
	 */
	private static Map<String, String> getOldHouseMJOrderMap(
			List<OldHouseFilterBean.OrderMJListEntity> orderMJList) {
		Map<String, String> MJMap = new LinkedHashMap<String, String>();
		MJMap.put("不限", "");
		for (OldHouseFilterBean.OrderMJListEntity orderMJListEntity : orderMJList) {
			MJMap.put(orderMJListEntity.orderMJName, "orderMJ=" + orderMJListEntity.orderMJID);//orderMJ=asc
		}
		return MJMap;
	}

	/**
	 * 获取租房  租金 排序方式
	 * @param orderRPList
	 * @return
	 */
	private static Map<String, String> getRentHousePriceMap(
			List<OrderRPListEntity> orderRPList) {
		Map<String, String> priceMap = new LinkedHashMap<String, String>();
		priceMap.put("不限", "");
		for (OrderRPListEntity orderRPListEntity : orderRPList) {
			priceMap.put(orderRPListEntity.orderRPName, "orderSP=" + orderRPListEntity.orderRPID); //orderRP=asc
		}
		return priceMap;
	}
	
	/**
	 * 获取二手房  总价 排序方式
	 * @param orderRPList
	 * @return
	 */
	private static Map<String, String> getOldHouseTotalPriceMap(
			List<OldHouseFilterBean.OrderSPListEntity> orderSPList) {
		Map<String, String> priceMap = new LinkedHashMap<String, String>();
		priceMap.put("不限", "");
		for (OldHouseFilterBean.OrderSPListEntity orderSPListEntity : orderSPList) {
			priceMap.put(orderSPListEntity.orderSPName, "orderSP=" + orderSPListEntity.orderSPID); //orderSP=asc
		}
		return priceMap;
	}
	/**
	 * 获取二手房  单价 排序方式
	 * @param orderRPList
	 * @return
	 */
	private static Map<String, String> getOldHouseUnitPriceMap(
			List<OldHouseFilterBean.OrderSUPListEntity> orderSUPList) {
		Map<String, String> priceMap = new LinkedHashMap<String, String>();
		priceMap.put("不限", "");
		for (OldHouseFilterBean.OrderSUPListEntity orderSUPListEntity : orderSUPList) {
			priceMap.put(orderSUPListEntity.orderSUPName, "orderSUP=" + orderSUPListEntity.orderSUPID); //orderSUP=asc
		}
		return priceMap;
	}

	/**
	 * 获取租房 户型筛选条件
	 * @param h_roomList
	 */
	private static Map<String, String> getRentHouseRoomMap(List<H_roomListEntity> h_roomList) {
		Map<String, String> houseType = new LinkedHashMap<String, String>();
		houseType.put("不限", "");
		for (H_roomListEntity roomListEntity : h_roomList) {
			houseType.put(roomListEntity.h_roomName, roomListEntity.h_roomID);
		}
		return houseType;
		
	}
	/**
	 * 获取二手房 户型筛选条件
	 * @param h_roomList
	 */
	private static Map<String, String> getOldHouseRoomMap(List<OldHouseFilterBean.H_roomListEntity> h_roomList) {
		Map<String, String> houseType = new LinkedHashMap<String, String>();
		houseType.put("不限", "");
		for (OldHouseFilterBean.H_roomListEntity roomListEntity : h_roomList) {
			houseType.put(roomListEntity.h_roomName, roomListEntity.h_roomID);
		}
		return houseType;
		
	}

	/**
	 * 获取租房 类型筛选
	 */
	private static Map<String, String> getRentHouseLXMap(List<Ho_lxListEntity> beanList) {
		Map<String, String> houseType = new LinkedHashMap<String, String>();
		houseType.put("不限", "");
		for (Ho_lxListEntity ho_lxListEntity : beanList) {
			houseType.put(ho_lxListEntity.LXName, ho_lxListEntity.LXID);
		}
		return houseType;
	}
	
	/**
	 * 获取二手房 类型筛选
	 */
	private static Map<String, String> getOldHouseLXMap(List<OldHouseFilterBean.Ho_lxListEntity> beanList) {
		Map<String, String> houseType = new LinkedHashMap<String, String>();
		houseType.put("不限", "");
		for (OldHouseFilterBean.Ho_lxListEntity ho_lxListEntity : beanList) {
			houseType.put(ho_lxListEntity.LXName, ho_lxListEntity.LXID);
		}
		return houseType;
	}

	public static HouseMoreSeleteCategoryBean getHouseMoreCategoryItem(
			String dispName, String urlKey, Map<String, String> structure) {
		HouseMoreSeleteCategoryBean categoryItem = new HouseMoreSeleteCategoryBean();
		categoryItem.name = dispName;
		categoryItem.urlKey = urlKey;
		List<HouseMoreCategoryItemValuesBean> values = new ArrayList<HouseMoreCategoryItemValuesBean>();
		HouseMoreCategoryItemValuesBean item;
		Set<Entry<String, String>> entrySet = structure.entrySet();
		for (Entry<String, String> entry : entrySet) {
			item = new HouseMoreCategoryItemValuesBean();
			item.name = entry.getKey();
			item.urlValue = entry.getValue();
			values.add(item);
		}
		categoryItem.values = values;
		return categoryItem;
	}

	public static HouseRegionBean createNewHouseRegionBean(int id, String name,
			boolean isSelete) {
		HouseRegionBean regionBean = new HouseRegionBean();
		regionBean.ZoneID = id;
		regionBean.ZoneName = name;
		regionBean.isSelete = isSelete;
		return regionBean;
	}

	public static List<HouseMoreSeleteCategoryBean> getNewHouseMoreCategoryBeans() {
		List<HouseMoreSeleteCategoryBean> houseMoreCategoryBeans = new ArrayList<HouseMoreSeleteCategoryBean>();
		{
			Map<String, String> concessions = new LinkedHashMap<String, String>();
			// 1=>优惠 2=>清盘 3=>团购
			concessions.put("不限", "");
			concessions.put("优惠", "1");
			concessions.put("清盘", "2");
			concessions.put("团购", "3");
			houseMoreCategoryBeans.add(getHouseMoreCategoryItem("优惠类型",
					"yh_type", concessions));
		}
		/*
		 * { Map<String, String> opentime = new LinkedHashMap<String, String>();
		 * opentime.put("不限", ""); opentime.put("一周内", "1");
		 * opentime.put("一个月内", "2"); opentime.put("三个月内", "3");
		 * opentime.put("半年内", "4"); opentime.put("一年内", "5");
		 * opentime.put("一年以上", "6");
		 * houseMoreCategoryBeans.add(getHouseMoreCategoryItem("开盘时间",
		 * "opentime", opentime)); }
		 */
		return houseMoreCategoryBeans;
	}

	public static List<OrderTypeBean> getOrderTypeBeans() {
		
		List<OrderTypeBean> list = new ArrayList<OrderTypeBean>();
		OrderTypeBean bean = new OrderTypeBean();
		bean.H_SaleOrRent_name = "不限";
		list.add(bean);
		bean = new OrderTypeBean();
		bean.H_SaleOrRent_name = "售房";
		bean.H_SaleOrRent_id = 1;
		list.add(bean);
		bean = new OrderTypeBean();
		bean.H_SaleOrRent_name = "租房";
		bean.H_SaleOrRent_id = 2;
		list.add(bean);
		return list;
	}

	public static List<OrderStateBean> getOrderStateBeans() {
		List<OrderStateBean> list = new ArrayList<OrderStateBean>();
		OrderStateBean bean = new OrderStateBean();
		bean.Order_Status_name = "不限";
		list.add(bean);
		bean = new OrderStateBean();
		bean.Order_Status_name = "等待付款";
		bean.Order_Status_id = 1;
		list.add(bean);
		bean = new OrderStateBean();
		bean.Order_Status_name = "已支付";
		bean.Order_Status_id = 2;
		list.add(bean);
		bean = new OrderStateBean();
		bean.Order_Status_name = "交易成功";
		bean.Order_Status_id = 3;
		list.add(bean);
		bean = new OrderStateBean();
		bean.Order_Status_name = "交易取消";
		bean.Order_Status_id = 4;
		list.add(bean);
		return list;
	}

}
